#include <bits/stdc++.h>
#include <string>
using namespace std;

char m[101][101];

void clearGrass(int r, int c, int i, int j)
{
    m[i][j] = '.';
    // 上 下 左 右
    if (i - 1 >= 0 && m[i - 1][j] == '#')
    {
        clearGrass(r, c, i - 1, j);
    }
    if (i + 1 < r && m[i + 1][j] == '#')
    {
        clearGrass(r, c, i + 1, j);
    }
    if (j - 1 >= 0 && m[i][j - 1] == '#')
    {
        clearGrass(r, c, i, j - 1);
    }
    if (j + 1 < c && m[i][j + 1] == '#')
    {
        clearGrass(r, c, i, j + 1);
    }
}

int main()
{
    int r, c, grass_count = 0;
    cin >> r >> c;
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> m[i][j];
        }
    }
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            if (m[i][j] == '#')
            {
                grass_count++;
                clearGrass(r, c, i, j);
            }
        }
    }
    cout << grass_count;
    return 0;
}
